package com.hebeu.group.service.impl;


import com.hebeu.group.mapper.FoodMapper;
import com.hebeu.group.pojo.Food;
import com.hebeu.group.pojo.FoodExample;
import com.hebeu.group.service.FoodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


import java.util.List;

@Service
public class FoodServiceImpl implements FoodService {

    private FoodMapper foodMapper;
    @Autowired
    public FoodServiceImpl(FoodMapper foodMapper){
        this.foodMapper=foodMapper;
    }


    /**
     * 查询单个菜品
     * @param food_id
     * @return
     */
    public Food selectSingleFood(int food_id){
        Food food=foodMapper.selectByPrimaryKey(food_id);
        return food;
    }


    /**
     * 查询所有菜品
     * @return
     */
    public List<Food> selectAllFood(){
        FoodExample foodExample=new FoodExample();
        FoodExample.Criteria criteria=foodExample.createCriteria();
        criteria.andFIdIsNotNull();
        List<Food> foodList=foodMapper.selectByExample(foodExample);
        return foodList;
    }

}
